<template>
    <div>
        <table class="table">
            <tbody>
                <tr>
                    <td>用户名</td>
                    <td><input v-model="obj.Uname"></td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input type="password" v-model="obj.Password"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="登录" @click="Login"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref} from 'vue';
import { onMounted } from 'vue';
import { useRoute,useRouter } from 'vue-router';
import axios from 'axios';
import moment from 'moment';
import {useuseStore} from '../stores/use';
const use =useuseStore();
const obj=ref({

  "Uname": "",
  "Password": "",
 
})

const Router=useRouter();
const Login=()=>{
    axios.get("https://localhost:7112/api/All/Login",{params:obj.value}).then(res=>{
        if(res.data==0)
    {
        alert('密码错误');
        return;
    }
    else if(res.data==-1)
    {
        alert('用户名不存在');
        return;
    }
    else{
        alert('登录成功');
        use.login.uname=obj.value.Uname;
        Router.push({path:"/add"});
    }
    })
}

</script>

<style scoped>

</style>